﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Security.ERP;
using Extra.ERP;
using Common.Class;

namespace Security.Security
{
    public class xfmGroups : XtraForm
    {
        private bool _search;
        private IContainer components;
        private xucGroup ucList;

        public event ItemSelectedEventHander ItemSelected;

        public xfmGroups()
        {
            this._search = false;
            this.components = null;
            this.InitializeComponent();
            this.Init();
        }

        public xfmGroups(bool search)
        {
            this._search = false;
            this.components = null;
            this._search = search;
            this.InitializeComponent();
            this.Init();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void Init()
        {
            SYS_LOG.Insert("Vai Tr\x00f2 Người D\x00f9ng", "Xem");
            this.ucList.CloseClick += new ButtonClickEventHander(this.ucList_CloseClick);
            this.Text = (SysOption.Language == "VN") ? this.Text : "Roles and Permision";
            this.ucList.Added += new xucGroup.AddedEventHander(this.ucList_Added);
        }

        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(xfmGroups));
            this.ucList = new xucGroup();
            base.SuspendLayout();
            this.ucList.Dock = DockStyle.Fill;
            this.ucList.IsClose = CloseOrNew.None;
            this.ucList.IsSearch = false;
            this.ucList.Location = new Point(0, 0);
            this.ucList.Name = "ucList";
            this.ucList.Size = new Size(0x3f4, 0x2de);
            this.ucList.Status = Actions.Add;
            this.ucList.TabIndex = 0;
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x3f4, 0x2de);
            base.Controls.Add(this.ucList);
            base.Icon = (Icon)manager.GetObject("$this.Icon");
            base.Name = "xfmGroups";
            this.Text = "Vai Tr\x00f2 & Quyền Hạn";
            base.ResumeLayout(false);
        }

        private void RaiseItemSelectedEventHander(SYS_GROUP item)
        {
            if (this.ItemSelected != null)
            {
                this.ItemSelected(this, item);
            }
        }

        private void ucList_Added(object sender, SYS_GROUP item)
        {
        }

        private void ucList_CloseClick(object sender)
        {
            base.Close();
        }

        public bool IsSearch
        {
            set
            {
                this.ucList.IsSearch = value;
            }
        }

        public delegate void ItemSelectedEventHander(object sender, SYS_GROUP item);
    }
}
